From 7e1a8fccf9a620393efbbd89579012d963a59a25 Mon Sep 17 00:00:00 2001 From: Imre Kaloz Date: Sun, 5 Feb 2006 23:59:37 +0000 Subject: [PATCH] add support for the Motorola WA840G and WE800G, and build the WRTSL54GS image, too SVN-Revision: 3155 --- openwrt/target/linux/image/brcm/Makefile | 20 ++++-- .../linux-2.4/patches/brcm/005-diag_led.patch | 71 ++++++++++--------- openwrt/target/utils/src/motorola-bin.c | 57 ++++++++++++--- 3 files changed, 99 insertions(+), 49 deletions(-) diff --git a/openwrt/target/linux/image/brcm/Makefile b/openwrt/target/linux/image/brcm/Makefile index 224d5eb6a3..9b28eb3914 100644 --- a/openwrt/target/linux/image/brcm/Makefile +++ b/openwrt/target/linux/image/brcm/Makefile @@ -62,19 +62,27 @@ $(BIN_DIR)/openwrt-wrt54g-$(FSNAME).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$ $(BIN_DIR)/openwrt-wrt54gs_v4-$(FSNAME).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx $(STAGING_DIR)/bin/addpattern -4 -p W54s -v v1.05.2 -i $< -o $@ -g -install: $(BIN_DIR)/openwrt-wrt54g-$(FSNAME).bin $(BIN_DIR)/openwrt-wrt54gs_v4-$(FSNAME).bin $(BIN_DIR)/openwrt-wrt54g3g-$(FSNAME).bin +$(BIN_DIR)/openwrt-wr850g-$(FSNAME).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx + $(STAGING_DIR)/bin/motorola-bin -1 $< $@ + +$(BIN_DIR)/openwrt-wa840g-$(FSNAME).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx + $(STAGING_DIR)/bin/motorola-bin -2 $< $@ + +$(BIN_DIR)/openwrt-we800g-$(FSNAME).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx + $(STAGING_DIR)/bin/motorola-bin -3 $< $@ + +install: $(BIN_DIR)/openwrt-wrt54g-$(FSNAME).bin $(BIN_DIR)/openwrt-wrt54gs_v4-$(FSNAME).bin $(BIN_DIR)/openwrt-wrt54g3g-$(FSNAME).bin $(BIN_DIR)/openwrt-wr850g-$(FSNAME).bin $(BIN_DIR)/openwrt-wa840g-$(FSNAME).bin $(BIN_DIR)/openwrt-we800g-$(FSNAME).bin endif ifneq ($(FS),jffs2-4MB) $(BIN_DIR)/openwrt-wrt54gs-$(FSNAME).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx $(STAGING_DIR)/bin/addpattern -4 -p W54S -v v4.70.6 -i $< -o $@ -g -install: $(BIN_DIR)/openwrt-wrt54gs-$(FSNAME).bin -endif +$(BIN_DIR)/openwrt-wrtsl54gs-$(FSNAME).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx + $(STAGING_DIR)/bin/addpattern -4 -p W54U -v v2.00.0 -i $< -o $@ -g -$(BIN_DIR)/openwrt-motorola-$(FS).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx - $(STAGING_DIR)/bin/motorola-bin $< $@ -install: $(BIN_DIR)/openwrt-motorola-$(FS).bin +install: $(BIN_DIR)/openwrt-wrt54gs-$(FSNAME).bin $(BIN_DIR)/openwrt-wrtsl54gs-$(FSNAME).bin +endif endif ifeq ($(IB),) diff --git a/openwrt/target/linux/linux-2.4/patches/brcm/005-diag_led.patch b/openwrt/target/linux/linux-2.4/patches/brcm/005-diag_led.patch index a1915223e6..7f896f8656 100644 --- a/openwrt/target/linux/linux-2.4/patches/brcm/005-diag_led.patch +++ b/openwrt/target/linux/linux-2.4/patches/brcm/005-diag_led.patch @@ -1,36 +1,7 @@ -diff -urN linux-2.4.30.dev/drivers/net/Makefile linux-2.4.30.dev2/drivers/net/Makefile ---- linux-2.4.30.dev/drivers/net/Makefile 2005-08-22 01:41:45.930653216 +0200 -+++ linux-2.4.30.dev2/drivers/net/Makefile 2005-08-22 01:58:04.162939304 +0200 -@@ -41,6 +41,8 @@ - obj-$(CONFIG_ISDN) += slhc.o - endif - -+subdir-m += diag -+ - subdir-$(CONFIG_HND) += hnd - subdir-$(CONFIG_ET) += et - subdir-$(CONFIG_WL) += wl -diff -urN linux-2.4.30.dev/drivers/net/diag/Makefile linux-2.4.30.dev2/drivers/net/diag/Makefile ---- linux-2.4.30.dev/drivers/net/diag/Makefile 1970-01-01 01:00:00.000000000 +0100 -+++ linux-2.4.30.dev2/drivers/net/diag/Makefile 2005-08-22 00:12:23.655170000 +0200 -@@ -0,0 +1,13 @@ -+#$Id$ -+ -+EXTRA_CFLAGS := -I$(TOPDIR)/arch/mips/bcm947xx/include -DBCMDRIVER -+ -+O_TARGET := diag.o -+ -+MAC_OBJS := diag_led.o -+ -+export-objs := -+obj-y := $(MAC_OBJS) -+obj-m := $(O_TARGET) -+ -+include $(TOPDIR)/Rules.make -diff -urN linux-2.4.30.dev/drivers/net/diag/diag_led.c linux-2.4.30.dev2/drivers/net/diag/diag_led.c ---- linux-2.4.30.dev/drivers/net/diag/diag_led.c 1970-01-01 01:00:00.000000000 +0100 -+++ linux-2.4.30.dev2/drivers/net/diag/diag_led.c 2005-08-22 03:37:58.112053448 +0200 -@@ -0,0 +1,248 @@ +diff -Nur linux-2.4.30/drivers/net/diag/diag_led.c linux-2.4.30.dev/drivers/net/diag/diag_led.c +--- linux-2.4.30/drivers/net/diag/diag_led.c 1970-01-01 01:00:00.000000000 +0100 ++++ linux-2.4.30.dev/drivers/net/diag/diag_led.c 2006-02-06 00:42:46.000000000 +0100 +@@ -0,0 +1,253 @@ +/* + * diag_led.c - replacement diag module + * @@ -219,6 +190,11 @@ diff -urN linux-2.4.30.dev/drivers/net/diag/diag_led.c linux-2.4.30.dev2/drivers + //asus wl-500g + reset_gpio=(1<<6); + } ++ if (!strcmp(buf,"2")) { ++ // wa840g v1 / we800g v1 ++ reset_gpio=(1<<0); ++ } ++ + } + if (!strcmp(buf,"bcm94710ap")) { + buf=nvram_get("boardnum")?:""; @@ -279,3 +255,32 @@ diff -urN linux-2.4.30.dev/drivers/net/diag/diag_led.c linux-2.4.30.dev2/drivers + +module_init(diag_init); +module_exit(diag_exit); +diff -Nur linux-2.4.30/drivers/net/diag/Makefile linux-2.4.30.dev/drivers/net/diag/Makefile +--- linux-2.4.30/drivers/net/diag/Makefile 1970-01-01 01:00:00.000000000 +0100 ++++ linux-2.4.30.dev/drivers/net/diag/Makefile 2006-02-05 15:35:11.000000000 +0100 +@@ -0,0 +1,13 @@ ++#$Id$ ++ ++EXTRA_CFLAGS := -I$(TOPDIR)/arch/mips/bcm947xx/include -DBCMDRIVER ++ ++O_TARGET := diag.o ++ ++MAC_OBJS := diag_led.o ++ ++export-objs := ++obj-y := $(MAC_OBJS) ++obj-m := $(O_TARGET) ++ ++include $(TOPDIR)/Rules.make +diff -Nur linux-2.4.30/drivers/net/Makefile linux-2.4.30.dev/drivers/net/Makefile +--- linux-2.4.30/drivers/net/Makefile 2006-02-05 15:34:40.000000000 +0100 ++++ linux-2.4.30.dev/drivers/net/Makefile 2006-02-05 15:35:11.000000000 +0100 +@@ -41,6 +41,8 @@ + obj-$(CONFIG_ISDN) += slhc.o + endif + ++subdir-m += diag ++ + subdir-$(CONFIG_HND) += hnd + subdir-$(CONFIG_ET) += et + subdir-$(CONFIG_WL) += wl diff --git a/openwrt/target/utils/src/motorola-bin.c b/openwrt/target/utils/src/motorola-bin.c index 476afe32f2..acf856dde6 100644 --- a/openwrt/target/utils/src/motorola-bin.c +++ b/openwrt/target/utils/src/motorola-bin.c @@ -1,8 +1,9 @@ /* * motorola-bin.c * - * Copyright (C) 2005 Mike Baker - * Openwrt.org + * Copyright (C) 2005-2006 Mike Baker, + * Imre Kaloz + * OpenWrt.org * * $Id$ * @@ -22,6 +23,12 @@ * */ +/* + * February 1, 2006 + * + * Add support for for creating WA840G and WE800G images + */ + #include #include #include @@ -59,29 +66,41 @@ unsigned int crc32buf(char *buf, size_t len) struct motorola { unsigned int crc; // crc32 of the remainder - unsigned int flags; // unknown, 10577050 + unsigned int flags; // unknown, 105770* char *trx; // standard trx }; +void usage(void) __attribute__ (( __noreturn__ )); + +void usage(void) +{ + printf("Usage: motorola-bin [-device] [trxfile] [binfile]\n\n"); + printf("Known devices: 1 - WR850G | 2 - WA840G | 3 - WE800G\n"); + exit(1); +} + int main(int argc, char **argv) { unsigned int len; int fd; + int c; void *trx; struct motorola *firmware; - if (argc<3) { - printf("%s \n",argv[0]); - exit(0); + // verify parameters + + if (argc!=4) + { + usage(); } // mmap trx file - if (((fd = open(argv[1], O_RDONLY)) < 0) + if (((fd = open(argv[2], O_RDONLY)) < 0) || ((len = lseek(fd, 0, SEEK_END)) < 0) || ((trx = mmap(0, len, PROT_READ, MAP_SHARED, fd, 0)) == (void *) (-1)) || (close(fd) < 0)) { perror("open/malloc"); - exit(-1); + exit(1); } // create a firmware image in memory @@ -92,11 +111,29 @@ int main(int argc, char **argv) // setup the motorola headers init_crc32(); - firmware->flags = ntohl(0x10577050); + + // setup the firmware magic + + while ((c = getopt(argc, argv, "123")) !=-1) { + switch (c) { + case '1': + firmware->flags = ntohl(0x10577050); // Motorola WR850G + break; + case '2': + firmware->flags = ntohl(0x10577040); // Motorola WA840G + break; + case '3': + firmware->flags = ntohl(0x10577000); // Motorola WE800G + break; + default: + usage(); + } + } + firmware->crc = htonl(crc32buf((char *)&firmware->flags,len+4)); // write the firmware - if (((fd = open(argv[2], O_CREAT|O_WRONLY,0644)) < 0) + if (((fd = open(argv[3], O_CREAT|O_WRONLY,0644)) < 0) || (write(fd,firmware,len+8) != len+8) || (close(fd) < 0)) { perror("write"); -- 2.30.2